package com.example.controller;

import com.alibaba.fastjson.JSON;
import com.example.common.R;
import com.example.service.ChannelService;
import com.example.service.impl.ChannelServiceImpl;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/channel")
public class ChannelServlet extends BaseServlet {


    /**
     * 获取频道列表数据
     *
     * @return
     * @throws Exception
     */
    public void getChannelList(HttpServletRequest req, HttpServletResponse resp) throws Exception {
        req.setCharacterEncoding("utf-8");

        ChannelService channelService = new ChannelServiceImpl();
        R channelList = channelService.getChannelList();
        //返回结果
        resp.setContentType("text/html");
        resp.setCharacterEncoding("UTF-8");
        resp.getWriter().write(JSON.toJSONString(channelList));
    }
}
